package com.ddwl.shop.dao;

import com.ddwl.common.dao.TkDao;
import com.ddwl.schema.vo.shop.ShopMemberDto;
import com.ddwl.shop.dao.mapper.ShopMemberMapper;
import com.ddwl.shop.dao.model.ShopMember;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * (ShopMember)表数据库访问层
 * @author wenbin
 */
@Slf4j
@Repository
public class ShopMemberDao extends TkDao<ShopMemberMapper, ShopMember> {

    public List<ShopMemberDto> queryMemberShopList(String userId) {
        return baseMapper.queryMemberShopList(userId);
    }

    public List<ShopMemberDto> queryParentShopList(String userId) {
        return baseMapper.queryParentShopList(userId);
    }

    public ShopMember checkMemberShop(String shopId, String memberShopId) {
        Example example = getExample();
        example.and()
                .andEqualTo("memberShopId",memberShopId)
                .andEqualTo("shopId",shopId);
        return baseMapper.selectOneByExample(example);
    }

    public ShopMember checkShop(String shopId, String userId) {
        Example example = getExample();
        example.and()
                .andEqualTo("userId",userId)
                .andEqualTo("memberShopId",shopId);
        return baseMapper.selectOneByExample(example);
    }
}